< previous page page_535 next page >

Page 535
CAUTION
Although having many different views of the data may be desirable, keeping multiple indexes can take a toll on performance, because all indexes must be updated each time data changes. Once again, you must consider the trade-offs in the database design.

note.gif You also can create different views of the information in a table by sorting the records or by specifying an order using the ORDER BY clause of a Structured Query Language (SQL) statement. Even though indexes aren't used directly by the SQL engine, their presence speeds up the sorting process when an ORDER BY clause is present. You learn about this topic in detail in Appendix C, "SQL Summary." square.gif

sarrow.gifSee ''Setting the Sort Conditions," p. 810
Single-Key Expressions
The most common type of index is the single-key index, which is based on the value of a single field in a table. Examples of this type of index are Social Security number, zip code, employee ID, and last name. If multiple records exist with the same index key, those records are presented in physical order within the sort order imposed by the single-key index. Figure 24.7 shows the physical order of a Names table and how the table appears after being indexed on the last name field.
0535-01.jpg
Figure 24.7
The physical and logical order of a table can be
different. Logical order depends on an index.
Multiple-Key Expressions
Although single-key expressions are valuable in presenting data in a specific order, imposing an even more detailed order on the table is often necessary. You can do so by using multiple-key indexes. As you can infer from the name, a multiple-key index is based on the values of two or more fields in a table. A prime example is to use last name and first name when indexing a membership list. Figure 24.8 updates the view of the table shown in Figure 24.7 to show how using the first name field to help sort the records changes the order of the table. As with single-key indexes, if the key values of several records are the same, the records are presented in physical order within the index order.

 
< previous page page_535 next page >